﻿<!--_meta 作为公共模版分离出去-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <script type="text/javascript" src="lib/PIE_IE678.js"></script>
    <![endif]-->
    <link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <script src="lib/jquery/1.9.1/jquery.min.js"></script>
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>添加库存信息</title>
</head>
<body>
    <article class="page-container">
        <form class="form form-horizontal" >
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>库存编码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder=""  id="Stock_Id" name="Stock_Id" readonly="readonly">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>仓库名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  id="WareHose_Name" name="WareHose_Name" readonly="readonly">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  id="Product_Name" name="Product_Name" readonly="readonly">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>当前库存：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value=""  id="Stock_num" name="Stock_num" readonly="readonly">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>盘点后数量：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" id="Blitem_num" name="Blitem_num">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>盘点单号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value=""  id="Blitem_Etc" name="Blitem_Etc">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>盘点类型：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select id="Slect1" class="input-text" style="width:100px;"></select>
                </div>
            </div>
            <input type="hidden" id="HiddenField1" />
            <input type="hidden" id="HiddenField2" />
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input type="button" class="btn btn-primary radius" value="盘点并生成盘点单" onclick="BlitemAdd()"/>
                </div>
            </div>
        </form>
    </article>
    <script>
        $(function () {
            var Stock_Id = getQueryStringByName("Stock_Id");
            alert(Stock_Id);
            $.ajax({
                type: "post",
                url: "Handler/Blitem.ashx/",
                data: { action: "GetPandianType" },
                dataType:"json",
                success: function (dd)
                {
                    $(dd).each(function (i, item) {
                        var str = '<option value="' + item["Blitem_Type_Id"] + '">' + item["Blitem_Type_name"] + '</option>'
                        $("#Slect1").append(str);
                    })
                }
            })
            $.ajax({
                type: "post",
                url: "Handler/Blitem.ashx/",
                data: {
                    action: "GetStockById",
                    Stock_Id:Stock_Id
                },
                dataType:"json",
                success: function (dd) {
                    $(dd).each(function (i, ss) {
                        $("#Stock_Id").val(ss["Stock_Id"]);
                        $("#WareHose_Name").val(ss["WareHose_Name"]);
                        $("#Product_Name").val(ss["Product_Name"]);
                        $("#Stock_num").val(ss["Stock_num"]);
                        $("#HiddenField1").val(ss["WareHose_Id"]);
                        $("#HiddenField2").val(ss["Product_Id"]);
                    })
                }
            })
        })

        function getQueryStringByName(name) {
            var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
            if (result == null || result.length < 1) {
                return "";
            }
            return result[1];
        }
        function BlitemAdd()
        {
            var Stock_Id = getQueryStringByName("Stock_Id");
            alert(Stock_Id)
            $.ajax({
                type: "post",
                url: "Handler/Blitem.ashx/",
                data: {
                    action: "BlitemAdd",
                    Blitem_Etc:     $("#Blitem_Etc").val()  ,
                    WareHose_Id:    $("#HiddenField1").val()    ,
                    Blitem_num:     $("#Blitem_num").val()  ,
                    Stock_Num:      $("#Blitem_num").val()  ,
                    Blitem_Stock_num: $("#Stock_num").val() ,
                    Blitem_Rownum: parseInt($("#Blitem_num").val()) - parseInt($("#Stock_num").val()),
                    Product_Id: $("#HiddenField2").val(),
                    Blitem_Type_Id: $("#Slect1").val(),
                    Stock_Id: Stock_Id
                },
                success: function (dd) {
                    if (dd > 0)
                    {
                        alert('添加成功!记得刷新页面');
                        //跳转盘点单显示界面
                        location.href = "BlitemShowMain.aspx";
                    }
                }
            })
        }
    </script>
    <!--_footer 作为公共模版分离出去-->
    <script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>
    <script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script>
    <script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="js/H-ui.js"></script>
    <script type="text/javascript" src="js/H-ui.admin.js"></script>
    <!--/_footer /作为公共模版分离出去-->
    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript">
        $(function () {
            $('.skin-minimal input').iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
                increaseArea: '20%'
            });

            $("#form-admin-add").validate({
                rules: {
                    adminName: {
                        required: true,
                        minlength: 4,
                        maxlength: 16
                    },
                    password: {
                        required: true,
                    },
                    password2: {
                        required: true,
                        equalTo: "#password"
                    },
                    sex: {
                        required: true,
                    },
                    phone: {
                        required: true,
                        isPhone: true,
                    },
                    email: {
                        required: true,
                        email: true,
                    },
                    adminRole: {
                        required: true,
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $(form).ajaxSubmit();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.$('.btn-refresh').click();
                    parent.layer.close(index);
                }
            });
        });
    </script>
    <!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
